
/*
 * panel_catat_pengembalian.java
 *
 * Created on Nov 25, 2011, 11:58:56 AM
 */
package Transaksi;

import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import Kasir.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.swing.Timer;

/**
 *
 * @author GRACE
 */
public class MencatatPengembalian extends javax.swing.JFrame {

    /** Creates new form panel_catat_pengembalian */
    public MencatatPengembalian() {
        initComponents();


        noNotaField.setEditable(true);

        dendaField.setText("0.0");
        dendaField.setEditable(false);


        jamText.setEditable(false);
        GregorianCalendar gc = new GregorianCalendar();
        DateChooser.setDate(gc.getTime());

        tglPinjamField.setText("" + new Date().toGMTString().substring(0, 10));
        tglPinjamField.setEditable(false);
        waktuPinjamField.setText("pukul : " + new Date().getHours());
        waktuPinjamField.setEditable(false);
        waktuKembaliField.setText(waktuPinjamField.getText());
        waktuKembaliField.setEditable(false);

        ActionListener taskPerformer = new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                String nol_jam = "";
                String nol_menit = "";
                String nol_detik = "";

                Date dt = new Date();

                int nilai_jam = dt.getHours();
                int nilai_menit = dt.getMinutes();
                int nilai_detik = dt.getSeconds();

                if (nilai_jam <= 9) {
                    nol_jam = "0";
                }

                if (nilai_menit <= 9) {
                    nol_menit = "0";
                }

                if (nilai_detik <= 9) {
                    nol_detik = "0";
                }

                String jam = nol_jam + Integer.toString(nilai_jam);
                String menit = nol_menit + Integer.toString(nilai_menit);
                String detik = nol_detik + Integer.toString(nilai_detik);

                jamText.setText(" " + jam + " : " + menit + " : " + detik + " ");

            }
        };
        new Timer(1000, taskPerformer).start();
    }

    private void setDatePengembalian() {
        java.util.Date curent = DateChooser.getDate();
        long curentTime = curent.getTime();
        long lamaHari = Long.parseLong(lamaPinjamField.getText());
        long lama = lamaHari * (24 * 60 * 60 * 1000);
        long kembali = curentTime + lama;
        java.util.Date dateKembali = new java.util.Date(kembali);
        SimpleDateFormat spdt = new SimpleDateFormat("dd MMM yyyy");
        String aaa = spdt.format(dateKembali);
        tglKembaliField.setText(aaa);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jPanel4 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        judulLabel = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        noNotaLabel = new javax.swing.JLabel();
        noNotaField = new javax.swing.JTextField();
        idKasirLabel = new javax.swing.JLabel();
        idKasirField = new javax.swing.JTextField();
        DateChooser = new com.toedter.calendar.JDateChooser();
        jamText = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        namaPenyewaField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        idPenyewaField = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        alamatField = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        tglPinjamField = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        waktuPinjamField = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        kodeMobilField = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        biayaField = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        dendaField = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        noTlpField = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        lamaPinjamField = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        tglKembaliField = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        waktuKembaliField = new javax.swing.JTextField();
        statusBayarComboBox = new javax.swing.JComboBox();
        simpanButton = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        totalBayartext = new javax.swing.JLabel();
        totalBayarField = new javax.swing.JTextField();
        back_button = new javax.swing.JButton();
        Cetak_button = new javax.swing.JButton();

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(jTable2);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1145, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 158, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(153, 0, 0));
        jPanel1.setForeground(new java.awt.Color(153, 0, 0));

        judulLabel.setFont(new java.awt.Font("Tahoma", 0, 18));
        judulLabel.setForeground(new java.awt.Color(255, 255, 0));
        judulLabel.setText("Transaksi Pengembalian Mobil");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(45, Short.MAX_VALUE)
                .addComponent(judulLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(42, 42, 42))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(judulLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel2.setBackground(new java.awt.Color(0, 0, 0));
        jPanel2.setForeground(new java.awt.Color(255, 204, 51));

        noNotaLabel.setForeground(new java.awt.Color(255, 255, 51));
        noNotaLabel.setText("No.Nota");

        noNotaField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                noNotaFieldKeyReleased(evt);
            }
        });

        idKasirLabel.setForeground(new java.awt.Color(255, 255, 0));
        idKasirLabel.setText("Id Kasir");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(noNotaLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(noNotaField, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(25, 25, 25)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(idKasirLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(idKasirField, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(30, 30, 30)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jamText)
                    .addComponent(DateChooser, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE))
                .addContainerGap(29, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(DateChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jamText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(noNotaLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(idKasirLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(noNotaField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(idKasirField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setBackground(new java.awt.Color(0, 0, 0));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Detail", javax.swing.border.TitledBorder.RIGHT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(153, 153, 153))); // NOI18N

        jLabel1.setForeground(new java.awt.Color(255, 255, 0));
        jLabel1.setText("Id Penyewa");

        jLabel2.setForeground(new java.awt.Color(255, 255, 0));
        jLabel2.setText("Nama Penyewa");

        jLabel3.setForeground(new java.awt.Color(255, 255, 0));
        jLabel3.setText("Alamat");

        jLabel4.setForeground(new java.awt.Color(255, 255, 0));
        jLabel4.setText("Tgl Pinjam");

        jLabel5.setForeground(new java.awt.Color(255, 255, 0));
        jLabel5.setText("Waktu Pinjam");

        jLabel6.setForeground(new java.awt.Color(255, 255, 0));
        jLabel6.setText("Kode Mobil");

        jLabel7.setForeground(new java.awt.Color(255, 255, 0));
        jLabel7.setText("Biaya");

        jLabel8.setForeground(new java.awt.Color(255, 255, 0));
        jLabel8.setText("Denda");

        jLabel9.setForeground(new java.awt.Color(255, 255, 0));
        jLabel9.setText("Status Pembayaran ");

        jLabel11.setForeground(new java.awt.Color(255, 255, 0));
        jLabel11.setText("No Telp");

        jLabel12.setForeground(new java.awt.Color(255, 255, 0));
        jLabel12.setText("Lama Peminjaman");

        jLabel13.setForeground(new java.awt.Color(255, 255, 0));
        jLabel13.setText("Tgl Kembali");

        jLabel14.setForeground(new java.awt.Color(255, 255, 0));
        jLabel14.setText("Waktu Kembali");

        statusBayarComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "LUNAS", "BELUM LUNAS" }));

        simpanButton.setText("Simpan");
        simpanButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                simpanButtonActionPerformed(evt);
            }
        });

        totalBayartext.setForeground(new java.awt.Color(255, 255, 0));
        totalBayartext.setText("Total Pembayaran");

        back_button.setText("Back");
        back_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                back_buttonActionPerformed(evt);
            }
        });

        Cetak_button.setText("Cetak");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addGroup(jPanel3Layout.createSequentialGroup()
                                                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                                                .addComponent(namaPenyewaField, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel3Layout.createSequentialGroup()
                                                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 78, Short.MAX_VALUE)
                                                .addComponent(idPenyewaField, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel3Layout.createSequentialGroup()
                                                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                                                .addComponent(alamatField, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel3Layout.createSequentialGroup()
                                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                    .addComponent(noTlpField)
                                                    .addComponent(tglPinjamField, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                                                    .addComponent(kodeMobilField, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)))
                                            .addGroup(jPanel3Layout.createSequentialGroup()
                                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel12)
                                                    .addComponent(jLabel13)
                                                    .addComponent(jLabel14))
                                                .addGap(49, 49, 49)
                                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addComponent(waktuKembaliField, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                                                        .addComponent(tglKembaliField, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                                                        .addComponent(lamaPinjamField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                                                        .addComponent(biayaField, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(dendaField, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                    .addComponent(waktuPinjamField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                        .addGap(789, 789, 789))
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addGap(129, 129, 129)
                                        .addComponent(back_button)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(simpanButton)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(Cetak_button)))
                                .addGap(452, 452, 452))
                            .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(statusBayarComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 367, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(78, 78, 78)
                        .addComponent(totalBayartext, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(totalBayarField, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(namaPenyewaField, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(idPenyewaField, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(alamatField, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(noTlpField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(kodeMobilField, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tglPinjamField, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(waktuPinjamField, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(lamaPinjamField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(tglKembaliField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(waktuKembaliField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(biayaField, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dendaField, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(statusBayarComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(27, 27, 27)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(19, 19, 19)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(totalBayartext, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(totalBayarField, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Cetak_button)
                    .addComponent(simpanButton)
                    .addComponent(back_button))
                .addGap(20, 20, 20))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, 0, 357, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void noNotaFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_noNotaFieldKeyReleased
        // TODO add your handling code here:
        try {
            Transaksi transaksi = new Transaksi();
            String noNota = noNotaField.getText();
            transaksi.setNo_Nota(noNota);

            transaksi = TransaksiKontrol.getKoneksiKontrol().cariTransaksi(transaksi);
            String namaPenyewa = transaksi.getNama_Penyewa();
            String idPenyewa = transaksi.getId_Penyewa();
            String alamatPenyewa = transaksi.getAlamat_Penyewa();
            String noTlp = transaksi.getNo_Tlp();
            String kodeMobil = transaksi.getKode_Mobil();
            String tglPinjam = transaksi.getTgl_Pinjam();
            int waktuPinjam = transaksi.getWaktu_Pinjam();
            int lamaPinjam = transaksi.getLama_Pinjam();
            String tglKembali = transaksi.getTgl_Kembali();
            int waktuKembali = transaksi.getWaktu_Kembali();
            double totalBiaya = transaksi.getTotal_Biaya();
            double denda = transaksi.getDenda();
            String statusBayar = transaksi.getStatus_Bayar();
            


            namaPenyewaField.setText(namaPenyewa);
            idPenyewaField.setText(idPenyewa);
            alamatField.setText(alamatPenyewa);
            noTlpField.setText(noTlp);
            kodeMobilField.setText(kodeMobil);
            tglPinjamField.setText(tglPinjam);
            waktuPinjamField.setText(String.valueOf(waktuPinjam));
            lamaPinjamField.setText(String.valueOf(lamaPinjam));
            tglKembaliField.setText(tglKembali);
            waktuKembaliField.setText(String.valueOf(waktuKembali));
            biayaField.setText(String.valueOf(totalBiaya));
            dendaField.setText(String.valueOf(denda));
            statusBayarComboBox.setSelectedItem(statusBayar);
            
            totalBayarField.setText(String.valueOf(totalBiaya + denda));

            namaPenyewaField.setEditable(false);
            idPenyewaField.setEditable(false);
            alamatField.setEditable(false);
            noTlpField.setEditable(false);
            kodeMobilField.setEditable(false);
            tglPinjamField.setEditable(false);
            waktuPinjamField.setEditable(false);
            lamaPinjamField.setEditable(false);
            totalBayarField.setEditable(false);
            

        } catch (Exception e) {
            Logger.getLogger(MencatatPengembalian.class.getName()).log(Level.SEVERE, null, e);

        }

    }//GEN-LAST:event_noNotaFieldKeyReleased

    private void simpanButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_simpanButtonActionPerformed
        // TODO add your handling code here:

        try {
            String noNota = noNotaField.getText();
            String namaPenyewa = namaPenyewaField.getText();
            String idPenyewa = idPenyewaField.getText();
            String alamatPenyewa = alamatField.getText();
            String noTlp = noTlpField.getText();
            String kodeMobil = kodeMobilField.getText();
            String tglPinjam = tglPinjamField.getText();
            int waktuPinjam = Integer.parseInt(waktuPinjamField.getText());
            int lamaPinjam = Integer.parseInt(lamaPinjamField.getText());
            String tglKembali = tglKembaliField.getText();
            int waktuKembali = Integer.parseInt(waktuKembaliField.getText());
            double totalBiaya = Double.parseDouble(biayaField.getText());
            double denda = Double.parseDouble(dendaField.getText());
            String statusBayar = statusBayarComboBox.getSelectedItem().toString();



            Transaksi transaksiBaru = new Transaksi();
            transaksiBaru.setNo_Nota(noNota);
            transaksiBaru.setNama_Penyewa(namaPenyewa);
            transaksiBaru.setId_Penyewa(idPenyewa);
            transaksiBaru.setAlamat_Penyewa(alamatPenyewa);
            transaksiBaru.setNo_Tlp(noTlp);
            transaksiBaru.setKode_Mobil(kodeMobil);
            transaksiBaru.setTgl_Pinjam(tglPinjam);
            transaksiBaru.setWaktu_Pinjam(waktuPinjam);
            transaksiBaru.setLama_Pinjam(lamaPinjam);
            transaksiBaru.setTgl_Kembali(tglKembali);
            transaksiBaru.setWaktu_Kembali(waktuKembali);
            transaksiBaru.setTotal_Biaya(totalBiaya);
            transaksiBaru.setDenda(denda);
            transaksiBaru.setStatus_Bayar(statusBayar);

            TransaksiKontrol transaksiKontrol = TransaksiKontrol.getKoneksiKontrol();
            transaksiKontrol.tambahTransaksi(transaksiBaru);


            JOptionPane.showMessageDialog(this, " " + noNota + " berhasil diupdate");
        } catch (SQLException ex) {
            Logger.getLogger(MencatatPengembalian.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(this, "Data transaksi gagal diupdate.");
        }

    }//GEN-LAST:event_simpanButtonActionPerformed

    private void back_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_back_buttonActionPerformed

        new FrameUtamaKasir().setVisible(true);
        this.setVisible(false);
        // TODO add your handling code here:
    }//GEN-LAST:event_back_buttonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MencatatPengembalian().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Cetak_button;
    private com.toedter.calendar.JDateChooser DateChooser;
    private javax.swing.JTextField alamatField;
    private javax.swing.JButton back_button;
    private javax.swing.JTextField biayaField;
    private javax.swing.JTextField dendaField;
    private javax.swing.JTextField idKasirField;
    private javax.swing.JLabel idKasirLabel;
    private javax.swing.JTextField idPenyewaField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTable jTable2;
    private javax.swing.JTextField jamText;
    private javax.swing.JLabel judulLabel;
    private javax.swing.JTextField kodeMobilField;
    private javax.swing.JTextField lamaPinjamField;
    private javax.swing.JTextField namaPenyewaField;
    private javax.swing.JTextField noNotaField;
    private javax.swing.JLabel noNotaLabel;
    private javax.swing.JTextField noTlpField;
    private javax.swing.JButton simpanButton;
    private javax.swing.JComboBox statusBayarComboBox;
    private javax.swing.JTextField tglKembaliField;
    private javax.swing.JTextField tglPinjamField;
    private javax.swing.JTextField totalBayarField;
    private javax.swing.JLabel totalBayartext;
    private javax.swing.JTextField waktuKembaliField;
    private javax.swing.JTextField waktuPinjamField;
    // End of variables declaration//GEN-END:variables
}
